//
//  FANEmoticonButton.m
//  Weibo - OC
//
//  Created by user on 16/5/2.
//  Copyright © 2016年 user. All rights reserved.
//

#import "FANEmoticonButton.h"
#import "NSString+Emoji.h"
#import "FANEmoticonViewModel.h"

@implementation FANEmoticonButton

- (void)setEmoticon:(FANEmoticon *)emoticon{
    
    _emoticon = emoticon;
    
    if (emoticon == nil) {
        
        return;
    }
    
    if ([emoticon.type isEqualToString:@"1"]) {
        
        [self setImage:nil forState:UIControlStateNormal];
        
        [self setTitle:[emoticon.code emoji]  forState:UIControlStateNormal];
        
        self.titleLabel.font = [UIFont systemFontOfSize:33];
        
    }else{
        
        NSString *imageString = [NSString stringWithFormat:@"%@/%@",emoticon.folderName,emoticon.png];
        
        UIImage *image = [UIImage imageNamed:imageString inBundle:[FANEmoticonViewModel sharedEmoticon].bundle compatibleWithTraitCollection:nil];
        
        [self setImage:image forState:UIControlStateNormal];
        
        [self setTitle:nil forState:UIControlStateNormal];
    }
    
}

@end
